package com.jin.webvideo.config;

import com.jin.webvideo.base.spring.interceptor.WebSocketHandshakeInterceptor;
import com.jin.webvideo.websocket.shareroom.ShareRoomHandler;
import com.jin.webvideo.websocket.shareroom.ShareRoomManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

@Configuration
public class WebSocketConfig implements WebSocketConfigurer {
    @Autowired
    private ShareRoomHandler handler;
    @Autowired
    private ShareRoomManager manager;
    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        // websocket 共享放映室拦截器
        WebSocketHandshakeInterceptor interceptor = new WebSocketHandshakeInterceptor(manager);
        registry.addHandler(handler,"/api/shareroom/*")
                .addInterceptors(interceptor);
    }
}
